namespace PHMEE.PHM.Algorithms.Basic;

/// <summary>
/// 滤波包络算法
/// </summary>
public sealed class FilterEnvelopeAlg
{
    private readonly FilterEnvelopeService.FilterEnvelopeServiceClient _client;

    public FilterEnvelopeAlg(FilterEnvelopeService.FilterEnvelopeServiceClient client)
    {
        _client = client;
    }
    
    /// <summary>
    /// 滤波包络算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <returns></returns>
    public FilterEnvelopeResponse FilterEnvelope(float[] accData, float sampleRate)
    {
        var request = new FilterEnvelopeRequest
        {
            AccData = {accData},
            SampleRate = sampleRate,
        };
        
        return _client.FilterEnvelopeAlg(request);
    }
    
    /// <summary>
    /// 滤波包络算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <returns></returns>
    public async Task<FilterEnvelopeResponse> FilterEnvelopeAsync(float[] accData, float sampleRate)
    {
        var request = new FilterEnvelopeRequest
        {
            AccData = {accData},
            SampleRate = sampleRate,
        };
        
        return await _client.FilterEnvelopeAlgAsync(request);
    }
}